
#include "Buffer.h"

const std::string &Buffer::buf() const { return m_buf; }

const char *Buffer::c_str() const { return m_buf.c_str(); }

void Buffer::set_buf(const char *buf) {
  std::string new_buf(buf);
  m_buf.swap(new_buf);
}

size_t Buffer::Size() const { return m_buf.size(); }

void Buffer::Append(const char *str, int size) {
  for (int i = 0; i < size; ++i) {
    if (str[i] == '\0') {
      break;
    }
    m_buf.push_back(str[i]);
  }
}

void Buffer::Clear() { m_buf.clear(); }
